import request from "@/utils/request"

/**
 * 获取角色列表
 * @returns {AxiosPromise}
 */
export const getRoleList = (params) => {
  return request({
    url: '/sys/role',
    method: 'GET',
    params
  })
}

/**
 * 新增角色
 * @param data
 * @returns {AxiosPromise}
 */
export const addRole = (data) => {
  return request({
    url: '/sys/role',
    method: 'POST',
    data
  })
}

/**
 * 更新角色
 * @param data
 * @returns {AxiosPromise}
 */
export const updateRole = (data) => {
  return request({
    url: `/sys/role/${data.id}`,
    method: 'PUT',
    data
  })
}

/**
 * 删除角色
 * @param id
 * @returns {AxiosPromise}
 */
export const delRole = (id) => {
  return request({
    url: `/sys/role/${id}`,
    method: 'DELETE'
  })
}

/**
 * 获取角色详情
 * @param id
 * @returns {AxiosPromise}
 */
export const getRoleDetail = (id) => {
  return request({
    url: `/sys/role/${id}`,
    method: 'GET'
  })
}

/**
 * 给角色分配权限
 * @param data
 * @returns {AxiosPromise}
 */
export const assignPerm = (data) => {
  return request({
    url: '/sys/role/assignPrem',
    method: 'PUT',
    data
  })
}
